<?php
namespace Admin\Model;
use Think\Model;
class OrderModel extends Model {
	protected $tableName = 'order'; 

	/**
	 * 列表
	 */
	public function mselect() {
		$where = array();
		$order = 'mm_order.otime desc,mm_order.oid desc';

		//$count = $this->join('mm_address ON mm_order.ouserid = mm_address.openid')->where($where)->count(); 
		$list = $this->join('mm_address ON mm_order.ouserid = mm_address.openid')->where($where)->group('transaction_id')->order($order)->select(); 
		$count = count($list);
		$Page       = new \Think\Page($count,25);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show       = $Page->show();// 分页显示输出
		//进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list = $this->join('mm_address ON mm_order.ouserid = mm_address.openid')->where($where)->group('transaction_id')->order($order)->limit($Page->firstRow.','.$Page->listRows)->select(); 
		$page = intval($_GET['p']);
		if(empty($page)) {
			$page = 1;
		}
		$num = (($page-1)*25);
		return array(
			'list' => $list,
			'page' => $show,
			'num' => $num
		);
	}

	public function mselect2() {
		$where = array();
		$order = 'mm_order.otime desc,mm_order.oid desc';
		$list = $this->join('mm_address ON mm_order.ouserid = mm_address.openid')->where($where)->group('transaction_id')->order($order)->select(); 
		return $list;
	}

}
